<template>
	<view>
		<u-navbar  :title='title'></u-navbar>
		<view class="bd t1">
				<view style="text-align: center" v-if="!list.length">暂无数据</view>
				<view class="s-list">
					<view class="s-item u-border-bottom" v-for="(v, index) in list" :key="index" @tap="goDetail(v)">
						<view class="iconfont iconarrow-right u-m-r-20" style="font-size: 40upx; color: #c3c3c3"></view>
						<view style="font-size: 28upx; font-weight: 500; padding: 10upx 0" class="titles u-line-2">{{ v.title }}</view>
						<image :src="v.imgUrl" mode="aspectFit" style=" height: 100upx" class="imgs"></image>
					</view>
				</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:'' ,//专题名称
				list: [],
			};
		},
		onLoad(option) {
			const item = JSON.parse(decodeURIComponent(option.obj));
			console.log(item)
			this.title = item.specialName
			this.id = item.id
			this.getInjectPlan(1,item.id)
		},
		onReachBottom() {
			//console.log('触底了')
			if (this.page.isLastPage) return;
			this.getInjectPlanMore(this.page.pageNum + 1,this.id);
		},
		methods:{
			// 获取建议列表
			getInjectPlan(pageNumber,id) {
				let self = this;
				uni.showLoading({
					title: "加载中",
					mask: true,
				});
				setTimeout((s) => {
					uni.hideLoading();
				}, 5000);
				this.config
					.get("/proposal/getList", {
						pageNum: pageNumber ? pageNumber : 1,
						pageSize: "10",
						specialTopic:id
					})
					.then((res) => {
						console.log(res);
						uni.hideLoading();
						if (res.data.code === 200) {
							self.page = res.data.data;
							self.list = res.data.data.list || [];
						} else {
							if (res.data.code == "-201") {
								self.config.handleError(res.data);
							} else {
								uni.showToast({
									title: self.config.handleError(res.data),
									icon: "none",
								});
							}
						}
					});
			},
			getInjectPlanMore(pageNumber,id) {
			  let self = this;
			  uni.showLoading({ title: "加载中", mask: true });
			  setTimeout((s) => {
			    uni.hideLoading();
			  }, 5000);
			  this.config
			   .get("/proposal/getList", {
			   	pageNum: pageNumber ? pageNumber : 1,
			   	pageSize: "10",
			   	specialTopic:id
			   })
			    .then((res) => {
			      uni.hideLoading();
			      if (res.data.code === 200) {
			        self.page = res.data.data;
			        self.list = self.list.concat(res.data.data.list);
			      } else {
			        if (res.data.code == "-201") {
			          self.config.handleError(res.data);
			        } else {
			          uni.showToast({
			            title: self.config.handleError(res.data),
			            icon: "none",
			          });
			        }
			      }
			    });
			},
			goDetail(v) {
				uni.navigateTo({
					url: "/pages/main/child/backlog/suggest-detail?id=" +
						v.id +
						"&title=" +
						v.title,
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
.s-list {
		// padding: 30upx;
		// margin-top: 150px;

		.s-item {
			width: 100%;
			padding: 30rpx 0;
			display: flex;
			align-items: center;
			background-color: white;
			flex-direction: row-reverse;
			.titles{
				width: 260%;
			}
		}
	}
</style>
